﻿<UserControl
    x:Class="DvachBrowser3.Views.Partial.SinglePostCollectionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:DvachBrowser3.Views.Partial"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vm="using:DvachBrowser3.ViewModels"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:behaviors="using:DvachBrowser3.Behaviors"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400">

    <Grid>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="100*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <ContentPresenter Grid.Row="0" Content="{x:Bind Header, Mode=OneWay}" ContentTemplate="{x:Bind HeaderTemplate, Mode=OneWay}" />
            <FlipView Grid.Row="1" x:Name="MainList" ItemsSource="{x:Bind ViewModel.Posts, Mode=OneWay}" Background="Transparent" SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}">
                <FlipView.ItemTemplate>
                    <DataTemplate x:DataType="vm:IPostViewModel">
                        <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Visible">
                            <local:PostView ViewModel="{x:Bind}" MaxLines="{Binding ElementName=ThisControl, Path=MaxLines, Mode=OneWay}"
                                    ShowCounter="{Binding ElementName=ThisControl, Path=ShowCounter, Mode=OneWay}" 
                                    ShowPreviewSeparator="{Binding ElementName=ThisControl, Path=ShowPreviewSeparator, Mode=OneWay}"
                                    ShowFullThreadText="{Binding ElementName=ThisControl, Path=ShowFullThreadText, Mode=OneWay}"
                                    ShowFullPostButton="{Binding ElementName=ThisControl, Path=ShowFullPostButton, Mode=OneWay}"
                                    ShowFullThread="PostView_OnShowFullThread" ShowFullPost="PostView_OnShowFullPost"
                                    VerticalAlignment="Top">
                                <interactivity:Interaction.Behaviors>
                                    <behaviors:CleanListContentMarginBehavior NarrowThickness="{StaticResource CleanListPaddingNarrow}" NormalThickness="{StaticResource CleanListPadding}" />
                                    <behaviors:PopupMenuBehavior>
                                        <behaviors:PopupMenuBehavior.MenuFlyout>
                                            <MenuFlyout>
                                                <MenuFlyoutItem Text="Копировать текст" Tag="{x:Bind}" Click="CopyTextFlyoutItem_OnClick"/>
                                                <MenuFlyoutItem Text="Копировать ссылку" Tag="{x:Bind}" Click="CopyLinkFlyoutItem_OnClick" />
                                                <MenuFlyoutItem Text="Ответить" Tag="{x:Bind}" Click="PostQuoteFlyoutItem_OnClick"/>
                                            </MenuFlyout>
                                        </behaviors:PopupMenuBehavior.MenuFlyout>
                                    </behaviors:PopupMenuBehavior>
                                </interactivity:Interaction.Behaviors>
                            </local:PostView>
                        </ScrollViewer>
                    </DataTemplate>
                </FlipView.ItemTemplate>
            </FlipView>
            <ContentPresenter Grid.Row="2" Content="{x:Bind Footer, Mode=OneWay}" ContentTemplate="{x:Bind FooterTemplate, Mode=OneWay}" />
        </Grid>
    </Grid>
</UserControl>
